package cn.kgc.service.impl;

import cn.kgc.dao.SmbmsRoleDao;
import cn.kgc.entity.SmbmsRole;
import cn.kgc.service.SmbmsRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

/**
 * @author Rock
 * @create 2020-08-24 9:48
 */
@Service("SmbmsRoleService")
public class SmbmsRoleServiceImpl implements SmbmsRoleService {
    @Autowired
    private SmbmsRoleDao roleDao;

    /**
     * 查询所有角色
     *
     * @return
     */
    @Override
    public List<SmbmsRole> findAllRole() throws SQLException {
        return roleDao.getAllRole();
    }

    /**
     * 根据id查询角色
     *
     * @param id
     * @return
     */
    @Override
    public SmbmsRole findRoleById(Integer id) throws SQLException {
        return roleDao.getRoleById(id);
    }

    /**
     * 添加角色
     *
     * @param role
     * @return
     */
    @Override
    public Integer saveRole(SmbmsRole role) throws SQLException {
        return roleDao.addRole(role);
    }

    /**
     * 修改角色
     *
     * @param role
     * @return
     */
    @Override
    public Integer modifyRole(SmbmsRole role) throws SQLException {
        return roleDao.updateRole(role);
    }

    /**
     * 删除角色
     *
     * @param id
     * @return
     */
    @Override
    public Integer removeRole(Integer id) throws SQLException {
        return roleDao.delRole(id);
    }
}
